/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge;

import ru.jSkyRoom.factory.BridgeFactory;
import ru.jSkyRoom.factory.FinderByFormIdFactory;
import ru.jSkyRoom.finder.FinderByFormId;
import ru.jSkyRoom.interfaces.major.Major;
import ru.jSkyRoom.support.FormIdProducer;
import skyproc.GRUP_TYPE;

/**
 *
 * @author Rakev
 */
public class JSkyBridge<T> {

    private T rawObject;

    public JSkyBridge(T rawObject) {
        this.rawObject = rawObject;
    }

    public final T getRawObject() {
        return rawObject;
    }

    protected BridgeFactory getBridgeFactory() {
        return BridgeFactory.create();
    }

    protected FinderByFormIdFactory getFinderFactory() {
        return new FinderByFormIdFactory() {

            @Override
            protected <T extends Major> FinderByFormId<T> createFinder(GRUP_TYPE... lookingGrups) {
                return super.createFinder(lookingGrups);
            }
        };
    }

    protected FormIdProducer getIdProducer() {
        return FormIdProducer.create();
    }

    @Override
    public int hashCode() {
        return getRawObject().hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        if (obj.getClass().equals(this.getClass())) {
            final JSkyBridge<T> other = (JSkyBridge<T>) obj;
            return getRawObject().equals(other.getRawObject());
        }
        return false;
    }

    @Override
    public String toString() {
        return getRawObject().toString();
    }
}
